/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-02-17
*/
package com.rzico.account.entity;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.rzico.account.model.Attach;
import com.rzico.annotation.IgnoreSwaggerParameter;
import com.rzico.basics.entity.Member;
import lombok.Data;

import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;

/**
 * <pre>
 *   退款单数据库对象
 * </pre>
 * @author Rzico Boot
 * @version 1.0
 */
@Data
@JsonIgnoreProperties(value = {"handler"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@Table(name = "wx_refunds")
public class Refunds{
    /**
     * 付款方式.在线支付
     */
    public static Integer METHOD_ONLINE=0;
    /**
     * 付款方式.线下支付
     */
    public static Integer METHOD_OFFLINE=1;
    /**
     * 付款方式.余额支付
     */
    public static Integer METHOD_WALLET=2;
    /**
     * 付款方式.会员卡支付
     */
    public static Integer METHOD_CARD=3;

    /**
     * 付款状态.等待退款
     */
    public static Integer STATUS_WAITING=0;
    /**
     * 付款状态.提交成功
     */
    public static Integer STATUS_SUCCESS=1;
    /**
     * 付款状态.退款失败
     */
    public static Integer STATUS_FAILURE=3;
    /**
     * 付款状态.退款完成
     */
    public static Integer STATUS_REFUNDED=2;
    /**
     * 付款状态.取消退款
     */
    public static Integer STATUS_CANCELED=4;

    /**
     * 账款类型.订单支付
     */
    public static Integer TYPE_ORDER=0;
    /**
     * 账款类型.钱包充值
     */
    public static Integer TYPE_WALLET=1;
    /**
     * 账款类型.线下收款
     */
    public static Integer TYPE_CASHIER=3;
    /**
     * 账款类型.会员卡充值
     */
    public static Integer TYPE_CARD=5;


    @ApiModelProperty(value = "")
    @Id
    protected Long id;

    @ApiModelProperty(value = "是否删除")
    protected Boolean deleted;

    @ApiModelProperty(value = "创建日期")
    protected java.util.Date createDate;

    @ApiModelProperty(value = "修改日期")
    protected java.util.Date modifyDate;

    @ApiModelProperty(value = "退款金额")
    protected java.math.BigDecimal amount;

    @ApiModelProperty(value = "付款张数")
    protected java.math.BigDecimal quantity;

    @ApiModelProperty(value = "手续费")
    protected java.math.BigDecimal fee;

    @ApiModelProperty(value = "到期时间")
    protected java.util.Date expire;

    @ApiModelProperty(value = "备注")
    protected String memo;

    @ApiModelProperty(value = "方式 {0:在线支付,1:线下支付,2:余额支付,3:会员卡支付}")
    protected Integer method;

    @ApiModelProperty(value = "退款日期")
    protected java.util.Date refundsDate;

    @ApiModelProperty(value = "支付插件")
    protected String paymentPluginId;

    @ApiModelProperty(value = "付款方式（中文名）")
    protected String paymentPluginName;

    @ApiModelProperty(value = "退款单号")
    protected String sn;

    @ApiModelProperty(value = "付款凭证号(第三方ID)")
    protected String tranSn;

    @ApiModelProperty(value = "状态 {0:等待退款,1:确认退款,2:退款完成,3:退款失败,4.取消退款}")
    protected Integer status;

    @ApiModelProperty(value = "类型 {0:付款,1:充值,2.收款}")
    protected Integer type;

    @ApiModelProperty(value = "付款人(会员表)")
    protected Long memberId;

    @ApiModelProperty(value = "付款单")
    protected Long paymentId;

    @ApiModelProperty(value = "方向 {0:代付,1:直清,2:代清}")
    protected Integer way;

    @ApiModelProperty(value = "")
    protected Long shopId;

    @ApiModelProperty(value = "附加数据")
    protected String attach;

    @ApiModelProperty(value = "收款人")
    protected String employeeId;

    @ApiModelProperty(value = "归属企业")
    protected Long enterpriseId;

    @ApiModelProperty(value = "创建者")
    protected String createBy;

    @ApiModelProperty(value = "更新者")
    protected String modifyBy;

    @ApiModelProperty(value = "订单类型 {0:订单,1.咨询,2.测试,3.报名,4.课程,5.问答}")
    protected Integer orderType;

    @ApiModelProperty(value = "订单ID")
    protected Long orderId;

    @ApiModelProperty(value = "退款ID")
    protected Long askforId;

    @ApiModelProperty(value = "订单号")
    protected String orderSn;

    /**
     *  会员
     */
    @JsonIgnore
    @IgnoreSwaggerParameter
    protected Member member;


    public Attach decodeAttach() {
        if (getAttach()!=null) {
            return JSON.parseObject(getAttach(),Attach.class);
        } else {
            return null;
        }
    }

    public String getName() {
        Member member = getMember();
        if (member!=null) {
            return member.getName();
        } else {
            return null;
        }
    }

    public String getMobile() {
        Member member = getMember();
        if (member!=null) {
            return member.getMobile();
        } else {
            return null;
        }
    }

}
